def optimal_time_matching(state):
    """
    实验baseline ,选择负载最先处理完的设备  #max(传输负载/传输能力+计算负载/计算能力）
    :param state:
    :return:
    """
    devices = int(len(state[2:])/4)  #设备数
    task_c,task_b = state[0],state[1]

    min_t = float('inf')
    choose_device = -1
    for i in range(devices): #遍历设备
        # t = max(state[2+4*i+2]/(state[2+4*i]),state[2+4*i+1+2]/state[2+4*i+1])
        t = state[2 + 4 * i + 2] / (state[2 + 4 * i]) + state[2 + 4 * i + 1 + 2] / state[2 + 4 * i + 1]

        if t<min_t:
            min_t = t
            choose_device = i
    # print(f'状态数:{len(state[2:])} 设备数：{devices},选择设备{choose_device}')
    return choose_device



